package com.example.template.common.base.impl;

import com.example.template.common.base.BaseMapper;
import com.example.template.common.base.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @className: BaseServiceImpl
 * @description: 基础业务实现类
 * @author: Kuangkeli
 * @date: 2024/01/18 20:13
 **/
@Service
public class BaseServiceImpl<T> implements BaseService<T> {

    @Autowired
    private BaseMapper<T> baseMapper;

    @Override
    public boolean deleteByPrimaryKey(Object id) {
        return baseMapper.deleteByPrimaryKey(id) == 1;
    }

    @Override
    public boolean insert(T record) {
        return baseMapper.insert(record) == 1;
    }

    @Override
    public boolean insertSelective(T record) {
        return baseMapper.insertSelective(record) == 1;
    }

    @Override
    public T selectByPrimaryKey(Object id) {
        return baseMapper.selectByPrimaryKey(id);
    }

    @Override
    public boolean updateByPrimaryKeySelective(T record) {
        return baseMapper.updateByPrimaryKeySelective(record) == 1;
    }

    @Override
    public boolean updateByPrimaryKey(T record) {
        return baseMapper.updateByPrimaryKey(record) == 1;
    }

    @Override
    public boolean batchDelete(String ids) {
        return baseMapper.deleteByIds(ids) >= 0;
    }

}
